import { defineStore } from "pinia";
import { getUserInfoData } from "@/api/system.js"

export const systemStore = defineStore("system", {
    state: () => {
        return {
            imageInfo: {},
            account: "",
            password: "",
            name: "",
            sex: 1,
            identity: "",
            deptName: "",
            email: "",
        }
    },
    actions: {
        async getUserInfo(url) {
            const result = await getUserInfoData(url);
            if (result.data.status == 200) {
                this.imageInfo = result.data.data.imageInfo;
                this.account = result.data.data.account;
                this.password = result.data.data.password;
                this.name = result.data.data.name;
                this.sex = result.data.data.sex;
                this.identity = result.data.data.identity;
                this.deptName = result.data.data.deptName;
                this.email = result.data.data.email;

                console.log("this.account", this.account)

            }

        }
    },

}, {
    persist: {
        enabled: true,
        storage: localStorage,
        key: "system"
    }
})

